<?php
/**
 * Description of ContentUserDetail
 *
 * @author Honza, Kevin
 */
class ContentUserDetail implements IMainBody {

  public function getContent() {
    $content = '';
    $content .= '<h2>My details</h2>';

    $auth = Auth::getInstance();
    $identity = $auth->getIdentity();

    $sql = "select login,name, surname, street, cp, city, mobile, email, library_card_number, DATE_FORMAT(library_card_validity, '%Y-%m-%d') as library_card_validity from " . TBL_USERS .
            " join " . TBL_ADDRESSES . " using (id_address)" .
            " where id_user = " . $identity['id'];
    $result = DB::sql($sql);
    $person = $result[0];

    $content .= '<span class="titleColumn">Login</span>' . $person['login'] . BR;
    $content .= '<span class="titleColumn">Name</span>' . $person['name'] . BR;
    $content .= '<span class="titleColumn">Surname</span>' . $person['surname'] . BR;
    $content .= '<span class="titleColumn">Street</span>' . $person['street'] . BR;
    $content .= '<span class="titleColumn">Street number</span>' . $person['cp'] . BR;
    $content .= '<span class="titleColumn">City</span>' . $person['city'] . BR;
    $content .= '<span class="titleColumn">Email</span>' . $person['email'] . BR;
    $content .= '<span class="titleColumn">Mobile</span>' . $person['mobile'] . BR;

    $content .= BR . BR;

    if ($person['library_card_number']) {
      //has a library card
      $content .= '<span class="titleColumn">Library card number</span>' . $person['library_card_number'] . BR;
      $content .= '<span class="titleColumn">Valid to</span>' . $person['library_card_validity'] . BR;
    } else {
      //library card is missing
      $content .= "You don´t have your library card yet? <a href=\"#\">Ask</a> for it";
    }

    return $content;
  }

}

?>
